<?php
namespace app\index\controller;

use think\Facade\Config;
use think\Controller;

class UserBase extends Base
{

    function check_acl()
    {
        $acl = [
            'user_type' => OPER_TYPE_USER,
            'modules' => [
                MODULE_USER => '77',
            ],
        ];
    }

    function check_token()
    {
        $user_info = null;

        if ($this->argv['token'] == 'SUOZHANGBIEKAIQIANG') {
            $user_info = [
                'user_type' => OPER_TYPE_OPS,
                'id' => 'SYSTEM',
                'name' => '系统',
                'phone' => '9527',
                'channel' => 'SYSTEM',
            ];
        } else {
            $user_info = (new UserToken())->query_info($this->argv['token']);
        }

        if (empty($user_info)) {
            throw_myexception(E_TOKEN_ERROR, "校验TOKEN失败！");
        }

        \ApiOper::instance()->_user_info = $user_info;
        $this->user_info = $user_info;
        \RequestContext::$opid = $user_info['id'];
        \ApiOper::instance()->set_token($this->argv['token']);
    }

}
